package com.xlf.mail;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import freemarker.template.Configuration;
import freemarker.template.Template;

public class DealFtl {

	public static void getMailTemplate(String o_id ,String custerName, String custerAddress) {
		try {
			Configuration cfg = new Configuration();
			// 模板路径
			cfg.setDirectoryForTemplateLoading(new File("./config/"));
			Map<String, Object> product = new HashMap<String, Object>();
			// 功能模块
			product.put("o_id", o_id);
			product.put("custerName", custerName);
			product.put("custerAddress", custerAddress);
			// 模板名称
			Template template = cfg.getTemplate("send.ftl");
			Writer writer = new OutputStreamWriter(new FileOutputStream(
					"./config/send.txt"), "UTF-8");
			template.process(product, writer);
			writer.flush();
			writer.close();

		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}
